<template>
<div>
<home-header></home-header>
<home-swiper :swiperRes = "swiperRes"></home-swiper>
<home-icons :iconsRes = "iconsRes"></home-icons>
<home-recommend :recommendRes="recommendRes"></home-recommend>
<home-weekend :weekendRes = "weekendRes"></home-weekend>
</div>
</template>

<script>
// 引入 组件名称    来自  组件文件夹
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeRecommend from './components/Recommend'
import HomeWeekend from './components/Weekend'
import axios from 'axios'
export default {
  name: 'Home',
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeRecommend,
    HomeWeekend
  },
  data(){
    return{
      swiperRes:[],
      iconsRes:[],
      recommendRes:[],
      weekendRes:[],
    }
  },
  methods: {
    getHomeInfo(){
      axios.get('/api/index.json')
      .then(
        this.getHomeInfoSucc
      )
    },
    getHomeInfoSucc(res){
      if(res.data.ret && res.data.data){
          // this.city = res.data.data.city
        this.swiperRes = res.data.data.swiperList
        this.iconsRes = res.data.data.iconList
        this.recommendRes = res.data.data.recommendList
        this.weekendRes = res.data.data.weekendList
      }

    }
  },
  mounted (){
    this.getHomeInfo()
  }
}
</script>

<style>

</style>
